<?php require_once('common.php');
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pelayan extends Common {
	function __construct() {
		parent::__construct("pelayan");
	}

	public function index(){	
		$this->load->model(array('paket_makanan'));
		$data['packets'] = $this->paket_makanan->get()->result_array();
		$this->load->view('pelayan/landing_page', $data);
	}
	
	function save_pesanan(){
		$this->load->model('pesanan');
		$data_input = array('id_petugas' => $this->user_data['id_petugas'],
							'no_meja'	 => $this->input->post('no_meja'));
		
		$id_pesanan = $this->pesanan->add($data_input);
		
		//simpan pesanan paket makan
		$packets = $this->input->post('packets');
		$jumlah_paket = $this->input->post('jumlah_paket');
		if($packets != NULL){
			for($j = 0; $j < count($packets); $j++){
				$inp_paket = array('id_pesanan' => $id_pesanan,
								   'id_paket' => $packets[$j],
								   'jumlah' => $jumlah_paket[$j]);
				$this->pesanan->add_detail_pesanan($inp_paket);
			}
		}
		
		redirect(base_url()."index.php/pelayan/pesanan_sukses");
	}
	
	function pesanan_sukses(){
		$this->load->view('pelayan/pesanan_sukses');
	}
}